// Protocol3 二维码配置协议数据
// 从 protocols-qrcode-config.ts 迁移而来，转换为 Protocol3 格式

import { type QRCodeConfig, ProtocolType3, FieldType } from '../types/protocol3-types'

// 网址链接活码协议
const urlLinkQRCodeConfig: QRCodeConfig = {
  protocolId: 'PROTOCOL3_QRCODE_URL_LINK',
  protocolType: ProtocolType3.QR_CODE_CONFIG,
  codeType: 'DYNAMIC',
  name: '网址链接活码',
  version: '3.0.0',
  description: '生成指向网址链接的二维码，用户扫码后跳转到指定网址',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础信息',
      description: '活码的基本信息配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'qrCodeName',
          fieldName: '活码名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入活码名称',
          description: '活码的显示名称，用于标识和管理',
          helpText: '2-50个字符',
          validation: {
            minLength: 2,
            maxLength: 50,
            message: '活码名称长度应在2-50个字符之间'
          }
        },
        {
          fieldKey: 'url',
          fieldName: '目标网址',
          fieldType: FieldType.URL,
          required: true,
          defaultValue: '',
          placeholder: '请输入目标网址，如：https://www.example.com',
          description: '用户扫码后跳转的目标网址',
          helpText: '必须以http://或https://开头',
          validation: {
            pattern: '^https?://.*',
            message: '请输入有效的网址，必须以http://或https://开头'
          }
        },
        {
          fieldKey: 'description',
          fieldName: '描述',
          fieldType: FieldType.TEXTAREA,
          required: false,
          defaultValue: '',
          placeholder: '请输入描述信息',
          description: '活码的详细描述',
          uiProps: {
            rows: 3
          }
        }
      ],
      defaultValues: {
        qrCodeName: '',
        url: '',
        description: ''
      }
    },
    {
      sectionKey: 'advanced',
      sectionName: '高级设置',
      description: '活码的高级配置选项',
      icon: 'SettingOutlined',
      order: 2,
      collapsed: true,
      fields: [
        {
          fieldKey: 'maxScanCount',
          fieldName: '最大扫码次数',
          fieldType: FieldType.NUMBER,
          required: false,
          defaultValue: 0,
          placeholder: '0表示无限制',
          description: '活码最大扫码次数限制',
          helpText: '0-999999次',
          validation: {
            min: 0,
            max: 999999,
            message: '扫码次数应在0-999999之间'
          }
        },
        {
          fieldKey: 'expireTime',
          fieldName: '过期时间',
          fieldType: FieldType.DATETIME,
          required: false,
          defaultValue: '',
          placeholder: '请选择过期时间',
          description: '活码过期时间，过期后无法使用',
          helpText: '不设置表示永不过期'
        },
        {
          fieldKey: 'enableTracking',
          fieldName: '启用访问统计',
          fieldType: FieldType.SWITCH,
          required: false,
          defaultValue: true,
          description: '是否启用访问统计功能'
        }
      ],
      defaultValues: {
        maxScanCount: 0,
        expireTime: '',
        enableTracking: true
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['二维码', '网址链接'],
    category: '二维码配置',
    documentation: '网址链接活码配置协议'
  },
  enabled: true
}

// 文本信息活码协议
const textInfoQRCodeConfig: QRCodeConfig = {
  protocolId: 'PROTOCOL3_QRCODE_TEXT_INFO',
  protocolType: ProtocolType3.QR_CODE_CONFIG,
  codeType: 'DYNAMIC',
  name: '文本信息活码',
  version: '3.0.0',
  description: '生成包含文本信息的二维码，用户扫码后显示文本内容',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础信息',
      description: '文本活码的基本信息配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'qrCodeName',
          fieldName: '活码名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入活码名称',
          description: '活码的显示名称，用于标识和管理',
          helpText: '2-50个字符',
          validation: {
            minLength: 2,
            maxLength: 50,
            message: '活码名称长度应在2-50个字符之间'
          }
        },
        {
          fieldKey: 'textContent',
          fieldName: '文本内容',
          fieldType: FieldType.TEXTAREA,
          required: true,
          defaultValue: '',
          placeholder: '请输入要显示的文本内容',
          description: '用户扫码后显示的文本内容',
          helpText: '不超过1000个字符',
          uiProps: {
            rows: 5
          },
          validation: {
            maxLength: 1000,
            message: '文本内容不能超过1000个字符'
          }
        },
        {
          fieldKey: 'textFormat',
          fieldName: '文本格式',
          fieldType: FieldType.SELECT,
          required: false,
          defaultValue: 'PLAIN',
          options: [
            { label: '纯文本', value: 'PLAIN' },
            { label: 'Markdown', value: 'MARKDOWN' },
            { label: 'HTML', value: 'HTML' }
          ],
          description: '选择文本内容的格式'
        }
      ],
      defaultValues: {
        qrCodeName: '',
        textContent: '',
        textFormat: 'PLAIN'
      }
    },
    {
      sectionKey: 'advanced',
      sectionName: '高级设置',
      description: '文本活码的高级配置选项',
      icon: 'SettingOutlined',
      order: 2,
      collapsed: true,
      fields: [
        {
          fieldKey: 'maxScanCount',
          fieldName: '最大扫码次数',
          fieldType: FieldType.NUMBER,
          required: false,
          defaultValue: 0,
          placeholder: '0表示无限制',
          description: '活码最大扫码次数限制',
          helpText: '0-999999次',
          validation: {
            min: 0,
            max: 999999,
            message: '扫码次数应在0-999999之间'
          }
        },
        {
          fieldKey: 'expireTime',
          fieldName: '过期时间',
          fieldType: FieldType.DATETIME,
          required: false,
          defaultValue: '',
          placeholder: '请选择过期时间',
          description: '活码过期时间，过期后无法使用',
          helpText: '不设置表示永不过期'
        },
        {
          fieldKey: 'enableTracking',
          fieldName: '启用访问统计',
          fieldType: FieldType.SWITCH,
          required: false,
          defaultValue: true,
          description: '是否启用访问统计功能'
        }
      ],
      defaultValues: {
        maxScanCount: 0,
        expireTime: '',
        enableTracking: true
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['二维码', '文本信息'],
    category: '二维码配置',
    documentation: '文本信息活码配置协议'
  },
  enabled: true
}

// 联系人信息活码协议
const contactInfoQRCodeConfig: QRCodeConfig = {
  protocolId: 'PROTOCOL3_QRCODE_CONTACT_INFO',
  protocolType: ProtocolType3.QR_CODE_CONFIG,
  codeType: 'DYNAMIC',
  name: '联系人信息活码',
  version: '3.0.0',
  description: '生成包含联系人信息的二维码，用户扫码后可保存联系人',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础信息',
      description: '联系人活码的基本信息配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'qrCodeName',
          fieldName: '活码名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入活码名称',
          description: '活码的显示名称，用于标识和管理',
          helpText: '2-50个字符',
          validation: {
            minLength: 2,
            maxLength: 50,
            message: '活码名称长度应在2-50个字符之间'
          }
        },
        {
          fieldKey: 'contactName',
          fieldName: '联系人姓名',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系人姓名',
          description: '联系人的姓名',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '联系人姓名不能超过50个字符'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系电话',
          description: '联系人的电话号码',
          helpText: '11位手机号码',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的手机号码'
          }
        },
        {
          fieldKey: 'contactEmail',
          fieldName: '邮箱地址',
          fieldType: FieldType.INPUT,
          required: false,
          defaultValue: '',
          placeholder: '请输入邮箱地址',
          description: '联系人的邮箱地址',
          helpText: '有效的邮箱地址',
          validation: {
            pattern: '^[^@]+@[^@]+\\.[^@]+$',
            message: '请输入有效的邮箱地址'
          }
        },
        {
          fieldKey: 'organization',
          fieldName: '组织机构',
          fieldType: FieldType.INPUT,
          required: false,
          defaultValue: '',
          placeholder: '请输入组织机构',
          description: '联系人所属的组织或公司',
          helpText: '不超过100个字符',
          validation: {
            maxLength: 100,
            message: '组织机构不能超过100个字符'
          }
        },
        {
          fieldKey: 'position',
          fieldName: '职位',
          fieldType: FieldType.INPUT,
          required: false,
          defaultValue: '',
          placeholder: '请输入职位',
          description: '联系人的职位',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '职位不能超过50个字符'
          }
        }
      ],
      defaultValues: {
        qrCodeName: '',
        contactName: '',
        contactPhone: '',
        contactEmail: '',
        organization: '',
        position: ''
      }
    },
    {
      sectionKey: 'advanced',
      sectionName: '高级设置',
      description: '联系人活码的高级配置选项',
      icon: 'SettingOutlined',
      order: 2,
      collapsed: true,
      fields: [
        {
          fieldKey: 'maxScanCount',
          fieldName: '最大扫码次数',
          fieldType: FieldType.NUMBER,
          required: false,
          defaultValue: 0,
          placeholder: '0表示无限制',
          description: '活码最大扫码次数限制',
          helpText: '0-999999次',
          validation: {
            min: 0,
            max: 999999,
            message: '扫码次数应在0-999999之间'
          }
        },
        {
          fieldKey: 'expireTime',
          fieldName: '过期时间',
          fieldType: FieldType.DATETIME,
          required: false,
          defaultValue: '',
          placeholder: '请选择过期时间',
          description: '活码过期时间，过期后无法使用',
          helpText: '不设置表示永不过期'
        },
        {
          fieldKey: 'enableTracking',
          fieldName: '启用访问统计',
          fieldType: FieldType.SWITCH,
          required: false,
          defaultValue: true,
          description: '是否启用访问统计功能'
        }
      ],
      defaultValues: {
        maxScanCount: 0,
        expireTime: '',
        enableTracking: true
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['二维码', '联系人信息'],
    category: '二维码配置',
    documentation: '联系人信息活码配置协议'
  },
  enabled: true
}

// WiFi信息活码协议
const wifiInfoQRCodeConfig: QRCodeConfig = {
  protocolId: 'PROTOCOL3_QRCODE_WIFI_INFO',
  protocolType: ProtocolType3.QR_CODE_CONFIG,
  codeType: 'DYNAMIC',
  name: 'WiFi信息活码',
  version: '3.0.0',
  description: '生成包含WiFi信息的二维码，用户扫码后可快速连接WiFi',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础信息',
      description: 'WiFi活码的基本信息配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'qrCodeName',
          fieldName: '活码名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入活码名称',
          description: '活码的显示名称，用于标识和管理',
          helpText: '2-50个字符',
          validation: {
            minLength: 2,
            maxLength: 50,
            message: '活码名称长度应在2-50个字符之间'
          }
        },
        {
          fieldKey: 'wifiName',
          fieldName: 'WiFi名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入WiFi网络名称',
          description: 'WiFi网络的SSID',
          helpText: '不超过32个字符',
          validation: {
            maxLength: 32,
            message: 'WiFi名称不能超过32个字符'
          }
        },
        {
          fieldKey: 'wifiPassword',
          fieldName: 'WiFi密码',
          fieldType: FieldType.PASSWORD,
          required: false,
          defaultValue: '',
          placeholder: '请输入WiFi密码',
          description: 'WiFi网络的密码',
          helpText: '如果是开放网络可以不填'
        },
        {
          fieldKey: 'wifiSecurity',
          fieldName: '安全类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'WPA',
          options: [
            { label: '无密码(开放)', value: 'nopass' },
            { label: 'WEP', value: 'WEP' },
            { label: 'WPA/WPA2', value: 'WPA' }
          ],
          description: 'WiFi网络的安全类型'
        },
        {
          fieldKey: 'wifiHidden',
          fieldName: '隐藏网络',
          fieldType: FieldType.SWITCH,
          required: false,
          defaultValue: false,
          description: '是否为隐藏网络'
        }
      ],
      defaultValues: {
        qrCodeName: '',
        wifiName: '',
        wifiPassword: '',
        wifiSecurity: 'WPA',
        wifiHidden: false
      }
    },
    {
      sectionKey: 'advanced',
      sectionName: '高级设置',
      description: 'WiFi活码的高级配置选项',
      icon: 'SettingOutlined',
      order: 2,
      collapsed: true,
      fields: [
        {
          fieldKey: 'maxScanCount',
          fieldName: '最大扫码次数',
          fieldType: FieldType.NUMBER,
          required: false,
          defaultValue: 0,
          placeholder: '0表示无限制',
          description: '活码最大扫码次数限制',
          helpText: '0-999999次',
          validation: {
            min: 0,
            max: 999999,
            message: '扫码次数应在0-999999之间'
          }
        },
        {
          fieldKey: 'expireTime',
          fieldName: '过期时间',
          fieldType: FieldType.DATETIME,
          required: false,
          defaultValue: '',
          placeholder: '请选择过期时间',
          description: '活码过期时间，过期后无法使用',
          helpText: '不设置表示永不过期'
        },
        {
          fieldKey: 'enableTracking',
          fieldName: '启用访问统计',
          fieldType: FieldType.SWITCH,
          required: false,
          defaultValue: true,
          description: '是否启用访问统计功能'
        }
      ],
      defaultValues: {
        maxScanCount: 0,
        expireTime: '',
        enableTracking: true
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['二维码', 'WiFi信息'],
    category: '二维码配置',
    documentation: 'WiFi信息活码配置协议'
  },
  enabled: true
}

// 导出二维码配置协议数据数组
export const protocol3QRCodeConfigs: QRCodeConfig[] = [
  urlLinkQRCodeConfig,
  textInfoQRCodeConfig,
  contactInfoQRCodeConfig,
  wifiInfoQRCodeConfig
]